<p>There are two types of stream operations: intermediate operations, which return another stream, and terminal operations, which return something
other than a stream. Intermediate operations are lazy, meaning they aren’t actually executed until and unless a terminal stream operation is performed
on their results. Consequently if the result of an intermediate stream operation is not fed to a terminal operation, it serves no purpose, which is
almost certainly an error.</p>
<h2>Noncompliant Code Example</h2>
<pre>
widgets.stream().filter(b -&gt; b.getColor() == RED); // Noncompliant
</pre>
<h2>Compliant Solution</h2>
<pre>
int sum = widgets.stream()
                      .filter(b -&gt; b.getColor() == RED)
                      .mapToInt(b -&gt; b.getWeight())
                      .sum();
Stream&lt;Widget&gt; pipeline = widgets.stream()
                                 .filter(b -&gt; b.getColor() == GREEN)
                                 .mapToInt(b -&gt; b.getWeight());
sum = pipeline.sum();
</pre>
<h2>See</h2>
<ul>
  <li> <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html#StreamOps">Stream Operations</a> </li>
</ul>

